﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using eschoolBO;

namespace ESCHOOL.teachers
{
    public partial class WebForm12 : System.Web.UI.Page
    {
        teacher teach = new teacher();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Label1.Visible = false;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            DataTable dt = teach.GetRecords(Convert.ToInt64(Session["userid"]), "", "", "", "", "", "", -99, -99, -99, "",TextBox1.Text,"","","",false, " and ");
            if (dt.Rows.Count > 0)
            {
                teach.teacher_id = Convert.ToInt64(dt.Rows[0]["teacher_id"].ToString());
                teach.teacher_name = dt.Rows[0]["teacher_name"].ToString();
                teach.date_of_birth = dt.Rows[0]["date_of_birth"].ToString();
                teach.date_of_join = dt.Rows[0]["date_of_join"].ToString();
                teach.gender = dt.Rows[0]["gender"].ToString();
                teach.photo = dt.Rows[0]["photo"].ToString();
                teach.permanent_address = dt.Rows[0]["permanent_address"].ToString();
                teach.residence_pno = Convert.ToInt64(dt.Rows[0]["residence_pno"].ToString());
                teach.mobile_pno = Convert.ToInt64(dt.Rows[0]["mobile_pno"].ToString());
                teach.user_type_id = Convert.ToInt64(dt.Rows[0]["user_type_id"].ToString());
                teach.username = dt.Rows[0]["username"].ToString();
                teach.password = TextBox2.Text;
                teach.isdeleted = false;
                teach.SaveRecords();
                Label1.Text = "Your password has been changed."; Label1.Visible = true;
                Panel1.Visible = false;
            }
            else
            {
                Label1.Text = "Failed!try again."; Label1.Visible = true;
            }
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/teachers/Changepassword.aspx");
        }
    }
}
